//
//  ByDayEarningVC.m
//  mijifen_ios
//
//  Created by mc on 2017/10/26.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByDayEarningVC.h"

// other
#import "ZKSegmentControl.h"

// view
#import "ByViewDayEarningHeader.h"
#import "ByViewDayEarningIncome.h"
#import "ByViewDayEarningPay.h"
#import "ByViewDayEarningPointSwitch.h"


@interface ByDayEarningVC ()

@end

@implementation ByDayEarningVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的账单";
    [self addLeftBackBarButtonItem];
    [self createHeaderView];
    
    self.view.backgroundColor = BY_TABLE_COLOR;
}

#pragma mark - 创建视图
- (void)createHeaderView{
    ByViewDayEarningHeader *headerView = [[ByViewDayEarningHeader alloc] init];
    [self.view addSubview:headerView];
    [headerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        if (@available(iOS 11.0,*)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
        }else{
            make.top.equalTo(self.view.mas_top);
        }
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH, 120));
    }];
//    headerView.pointBlock = ^{
//        ByViewDayEarningPointSwitch *view = [[ByViewDayEarningPointSwitch alloc] init];
//        view.point = @"300000";
//        [view show];
//
//    };
    
    // 主视图
    ZKSegmentControl *control = [[ZKSegmentControl alloc] init];
    [self.view addSubview:control];
    [control mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left);
        make.top.equalTo(headerView.mas_bottom).offset(15);
        make.right.equalTo(self.view.mas_right);
        if (@available(iOS 11.0,*)) {
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        }else{
            make.bottom.mas_equalTo(self.view.mas_bottom);
        }
    }];
    control.segmentsArray = @[@"收入",@"支出"];
    control.segmentSelectTint = BY_TEXT_COLOR;
    control.backgroundColor = BY_TABLE_COLOR;
    
    control.dynamicalAddContentViewBlock = ^(void (^contentViewFetchBlock)(ZKSegmentContentView *contentView), NSInteger selectedIndex) {
        if (selectedIndex == 0) {
            ByViewDayEarningIncome *incomeView = [[ByViewDayEarningIncome alloc] init];
            if (contentViewFetchBlock) {
                contentViewFetchBlock(incomeView);
            }
        }else{
            ByViewDayEarningPay *payView = [[ByViewDayEarningPay alloc] init];
            if (contentViewFetchBlock) {
                contentViewFetchBlock(payView);
            }
        }
    };
    
}




- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
